#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 5e3 + 10, mod = 80112002;

int n, m;
vector<int> g[N];
int in[N], out[N], cnt[N];

void solve()
{
    cin >> n >> m;
    for (int i = 1;i <= m;i++) {
        int x, y;cin >> x >> y;
        g[x].push_back(y);
        out[x]++;in[y]++;
    }

    int ans = 0;
    queue<int> q;
    for (int i = 1;i <= n;i++) if (in[i] == 0) { q.push(i);cnt[i] = 1; }
    while (!q.empty()) {
        int x = q.front();q.pop();
        if (out[x] == 0) (ans += cnt[x]) %= mod;
        for (int y : g[x]) {
            in[y]--;
            (cnt[y] += cnt[x]) %= mod;
            if (in[y] == 0) q.push(y);
        }
    }
    cout << ans << '\n';
}

signed main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}